$(function() {
  $(':button#btndelivery').bind('click', function() {
    $.getJSON('/_deliveryflow', {
      pono: $('input[name="pono"]').val(),
      ssn: $('input[name="ssn"]').val(),
      date: new Date().getTime()+Math.random()
    }, function(data) {
      if(data.result == 'RELOGIN')
      {
        location.href = "/login";
      }
      else
      {
        $("#result").text(data.result);
        if($("#result").text() == "")
        {
          var d = new Date().format("yyyy-MM-dd hh:mm:ss");
          var s_ssn = ssn.value;
          var s_po = $("#pono").val();
          $("#flowdetail").val(d + "   " + s_ssn + " Delivery by PO: " + s_po + "\r" + $("#flowdetail").text());
        }
        else
        {
          alert(data.result);
        }
        ssn.value = "";
      }
    });
    return false;
  });
})

function txtKeyDown()
{
  if(event.keyCode == 13)
  {
    btndelivery.click();
    ssn.focus();
  }
}